package com.tengju.user.domain.model;

import com.fasterxml.jackson.core.type.TypeReference;
import com.tengju.user.domain.shared.JsonUtil;

import java.util.Map;

public class Row {

    private Map<String,Object> data;

    public Integer size() {
        return data.size();
    }

    public boolean containsKey(String key) {
        return data != null && data.containsKey(key);
    }

    public Object getValue(String key) {
        if (data == null) {
            return null;
        }
        return data.get(key);
    }

    public Row(Object obj) {
        this.data = JsonUtil.toMap(JsonUtil.toJSONString(obj),new TypeReference<>() {});
    }

}
